home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The CDPD Public Domain Collection for CDTV 4
/
CDPD_IV.bin
/
e
/
mailinglists
/
amigae.0294feb.archive
/
000048_donews!crash!h…m.ac.uk!dmh1002_Sat, 12 Feb 94 04:13:00 PST.msg
< prev
next >
Wrap
Internet Message Format
|
1994-05-26
|
2KB
Received: by bkhouse.cts.com (V1.17-beta/Amiga)
id <1taq@bkhouse.cts.com>; Sat, 12 Feb 94 04:13:00 PST
Received: from crash by donews.cts.com with uucp
(Smail3.1.28.1 #18) id m0pVIYJ-0001mhC; Sat, 12 Feb 94 06:30 EST
Received: from ppsw2.cam.ac.uk by crash.cts.com with smtp
(Smail3.1.28.1 #18) id m0pVILM-0000TzC; Sat, 12 Feb 94 03:17 PST
Received: from black.csi.cam.ac.uk by ppsw2.cam.ac.uk
with SMTP-CAM (PP-6.0) as ppsw.cam.ac.uk
id <08479-0@ppsw2.cam.ac.uk>; Sat, 12 Feb 1994 11:16:30 +0000
Received: from hermes.cam.ac.uk by black.csi.cam.ac.uk
id <24735-0@black.csi.cam.ac.uk>; Sat, 12 Feb 1994 11:15:56 +0000
Date: Sat, 12 Feb 1994 11:17:00 +0000 (GMT)
In-Reply-To: <5883:77010@fantasyfarm.com>
Message-ID: <Pine.3.89.9402121106.A15308-0100000@blue.csi.cam.ac.uk>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII
Sender: dmh1002@hermes.cam.ac.uk
From: Dave Higginson <dmh1002@hermes.cam.ac.uk>
To: The AmigaE Mailing List <AmigaE@bkhouse.cts.com>
Subject: Re: Bugs in the Mod() function
On Wed, 9 Feb 1994, Bernie Cosell wrote:
> After a lot of debugging of code that ought to have worked, I
> discovered that the Mod function seems to be VERY broken. As we
> [ought to] all know, taking an integer mod N should *always* get you
> an integer between 0 and n-1. Well, it ain't so in E. A simple
> test reveals:
In fact the Mod function is not broken at all. Virtually all mod
functions in computer languages work in the fashion you have described.
You'll just have to find a workaround if you want a strictly positive
answer, I'm afraid. You could try Mod(Mod(a,n)+n,n). Or, if your n is a
power of 2, use (a and (n-1)).
> Which is clearly broken. In the course of pursuing this, I discovered
> that simple division ain't a prize, either:
>
> Dividing 11 / 8 = 1
> Dividing 6 / 8 = 0
> Dividing 1 / 8 = 0
> Dividing -4 / 8 = 0
> Dividing -9 / 8 = -1
> Dividing -14 / 8 = -1
What answers were you expecting???
> It is astounding to me to try to understand arithmetic in an environment
> where:
>
> (A - B) / B does *NOT* equal (A / B) - 1
Ermm ... actually I think it does. Can you give an example where E does
not exhibit this behaviour?
Dave
+--
// David Higginson, dmh1002@hermes.cam.ac.uk
\X/ Churchill College, Cambridge, CB3 0DS, UK